package com.yupi.lkzyoj.judge.codeSandBox.config;

import com.yupi.lkzyoj.judge.codeSandBox.ICodeSandBox;
import com.yupi.lkzyoj.judge.codeSandBox.impl.ExampleCodeBoxSandBoxImpl;
import com.yupi.lkzyoj.judge.codeSandBox.impl.RemoteCodeBoxSandBoxImpl;
import com.yupi.lkzyoj.judge.codeSandBox.impl.ThirdPartyCodeBoxSandBoxImpl;
import com.yupi.lkzyoj.judge.codeSandBox.model.SandBoxConfigParams;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
public class SandBoxConfig {

    @Resource
    private SandBoxConfigParams params;

    @Bean
    public ICodeSandBox sandBoxConfiguration() {
        System.out.println("沙箱初始化...");
        if (params.getType().equals("example")) return new ExampleCodeBoxSandBoxImpl();
        if (params.getType().equals("remote")) return new RemoteCodeBoxSandBoxImpl();
        return new ThirdPartyCodeBoxSandBoxImpl();
    }

}
